package org.rency.crawler.fetch.repository.impl;

import javax.annotation.Resource;
import org.rency.crawler.dal.dao.FetchStateDao;
import org.rency.crawler.dal.entity.FetchStateDO;
import org.rency.crawler.domain.state.FetchStateDomain;
import org.rency.crawler.fetch.converter.DomainConvertor;
import org.rency.crawler.fetch.repository.FetchStateRepository;
import org.springframework.stereotype.Repository;

/**
 * 描述: ${TODO}<br>
 * 最近修改时间:2017/11/22 10:20<br>
 *
 * @author CaiyuRen
 * @version V1.0
 * @since 2017/11/22 10:20
 */
@Repository
public class FetchStateRepositoryImpl implements FetchStateRepository {

  @Resource
  private FetchStateDao fetchStateDao;

  @Resource(name = "fetchStateDomainConvertor")
  private DomainConvertor<FetchStateDomain, FetchStateDO> convertor;

  @Override
  public FetchStateDomain load(String id) {
    return convertor.convertDomain(fetchStateDao.load(id));
  }

  @Override
  public FetchStateDomain find(String fsCode) {
    return convertor.convertDomain(fetchStateDao.find(fsCode));
  }

  @Override
  public boolean save(FetchStateDomain domain) {
    return fetchStateDao.save(convertor.convertEntity(domain));
  }

  @Override
  public boolean delete(String id) {
    return fetchStateDao.delete(id);
  }
}
